package com.itheima.test0910.test01;

import java.util.Date;

public class DateTest {
    public static void main(String[] args) {

        //获取当前本地电脑时间
        Date now = new Date();
        System.out.println(now);//Thu Sep 10 09:34:20 CST 2020
        //获取时间毫秒数       与0L -->  1970.1.1 00:00:00
        long time = now.getTime();
        System.out.println(time);//1599701660006
        long day = 1000*60*60*24L;
        //回溯时间一天
//        now.setTime(time - day);
        System.out.println(now);//Thu Sep 10 09:34:20 CST 2020

        //获取年份
        int year = now.getYear();
        System.out.println("年:" + (year + 1900));//年:2020
        //获取月份
        int month = now.getMonth();
        System.out.println("月:" + (month + 1));//月:9
        //获取天
        int week = now.getDay();
        int day1 = now.getDate();
        System.out.println("星期几:" + week);//星期几:4
        System.out.println("几号:" + day1);//几号:10
        //获取小时
        int hours = now.getHours();
        System.out.println("几小时:" + hours);//几小时:9
        //获取分钟
        int minutes = now.getMinutes();//分钟：34
        System.out.println("分钟：" + minutes);
        //获取秒
        int seconds = now.getSeconds();//秒：20
        System.out.println("秒：" + seconds);
    }
}
